package com.yuyou.tas.report.mapper;

import com.yuyou.tas.report.service.impl.SqlProvider;
import com.yuyou.tas.report.vo.ExcelStudentScore;
import com.yuyou.tas.report.vo.resp.IsExistResp;
import com.yuyou.tas.report.vo.resp.StudentRecordVo;
import com.yuyou.tas.service.api.report.entity.ExamModelReport;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.SelectProvider;

import java.util.List;
import java.util.Map;

@Mapper
public interface ExamModelReportMapper {
	
    /**
     * 检查报告是否开放
     * @param id
     * @return
     */
	Integer checkReportUse(Long id);
	
    int deleteByPrimaryKey(Long id);

    int insert(ExamModelReport record);

    void insertBatch(@Param(value = "list") List<ExamModelReport> list);

    ExamModelReport selectByPrimaryKey(Long id);

    int updateByPrimaryKeySelective(ExamModelReport record);

    void deleteByStudentExamClass(@Param(value = "stuId") Long stuId , @Param(value = "examId") Long examId , @Param(value = "lessonClassId") Long lessonClassId);

    void deleteByClassActivity(@Param(value = "stuId") Long stuId , @Param(value = "activityId") Long activityId , @Param(value = "lessonClassId") Long lessonClassId);
    
    ExamModelReport selectOne(@Param(value = "authOrganizationId")Long authOrganizationId,@Param(value = "lessonClassId")Long lessonClassId,@Param(value = "studentId")Long studentId);

    List<StudentRecordVo> getStudents(@Param(value = "classId")Long classId , @Param(value = "modelId")Long modelId ,@Param(value = "organId") Long organId);

    List<StudentRecordVo> getStudentsReports(@Param(value = "classId")Long classId ,@Param(value = "activityId") Long activityId);

    Integer countReportByModelId(@Param(value = "modelId")Long modelId);

    Integer deleteReportByModelId(@Param(value = "modelId")Long modelId);

    IsExistResp findStuReportByActivityClass(@Param(value = "activityId")Long activityId , @Param(value = "stuId")Long stuId , @Param(value = "classId")Long classId);

    List<ExcelStudentScore> findStudentScore(@Param(value = "isManage") Boolean isManage, @Param(value = "authUserId") Long authUserId, @Param(value = "examModelActivityId") Long examModelActivityId,
                                             @Param(value = "baseSchoolIdList") List<Long> baseSchoolIdList, @Param(value = "baseTrimesterId") Long baseTrimesterId,
                                             @Param(value = "baseSectionIdList") List<Long> baseSectionIdList, @Param(value = "dataSubjectIdList") List<Long> dataSubjectIdList);

    Integer selectMaxSortOfQuestion(@Param(value = "isManage") Boolean isManage, @Param(value = "authUserId") Long authUserId, 
    								@Param(value = "examModelActivityList") List<Long> examModelActivityList,
                                    @Param(value = "baseSchoolIdList") List<Long> baseSchoolIdList, @Param(value = "baseTrimesterId") Long baseTrimesterId,
                                    @Param(value = "baseSectionIdList") List<Long> baseSectionIdList, @Param(value = "dataSubjectIdList") List<Long> dataSubjectIdList);


    @SelectProvider(type = SqlProvider.class , method = "findStudentScoreNew")
    List<Map<String ,String>> findStudentScoreNew(@Param(value = "isManage") Boolean isManage, @Param(value = "authUserId") Long authUserId,
                                                  @Param(value = "maxSort") Integer maxSort,
                                                  @Param(value = "examModelActivityIds") List<Long> examModelActivityIds,
                                                  @Param(value = "baseSchoolIds") List<Long> baseSchoolIdList, @Param(value = "baseTrimesterId") Long baseTrimesterId,
                                                  @Param(value = "baseSectionIds") List<Long> baseSectionIdList, @Param(value = "dataSubjectIds") List<Long> dataSubjectIdList);
}